package com.zl.learning.object.event;

import lombok.Data;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

public class TestA {

    private List<Consumer<TestA>> subscriber = new ArrayList<>();

    @Getter
    private String data;

    public void addEvent(Consumer<TestA> consumer) {
        subscriber.add(consumer);
    }

    public void doChange() {
        data = "zhangsan";
        subscriber.forEach(r -> r.accept(this));
    }
}
